<%@page pageEncoding="utf-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<base href="/beadhouse/">
		<link rel="stylesheet" href="about/css/bootstrap.min.css">
		<link href="about/css/myCss.css" type="text/css" rel="stylesheet">
		<link href="about/css/main.css" type="text/css" rel="stylesheet">
		<link href="about/css/base.css" type="text/css" rel="stylesheet">
		<!--按钮样式表-->
		<link href="about/css/btn.css" type="text/css" rel="stylesheet">
		<link href="about/css/css.css" type="text/css" rel="stylesheet">
		<link href="about/css/index.css" type="text/css" rel="stylesheet">
		<link href="about/css/search.css" type="text/css" rel="stylesheet">
		<script src="about/js/jquery.min.js"></script>
		<script src="about/js/bootstrap.min.js"></script>
		<title>护理内容配置</title>
		<script type="text/javascript">
		 function GetQueryString(name){
				var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
				var r = window.location.search.substr(1).match(reg);
				if(r!=null)return  unescape(r[2]); return null;

		}
		
		function deleteAllContent(){
			$hash = location.hash.substr(1);
			if($hash===""){
				$hash=GetQueryString("levelId");
			}
			$("#nurLevelId").val($hash);
			var url="/beadhouse/api/nurlevel/content/selectall";
			$.get(url,{},function(r){
				if(r.code==="ok"){
					paitNurContent(r.data);
				}
			});
		}
		var paitNurContent=function(data){
			var html="";
			for(var i=0;i<data.length;i++){
				html+="<option value="+data[i].id+">"+data[i].name+"</option>";
			}
			$("#contentSelect").html(html);
		}
		
		function Values(cid,lid){
			$("#levelId").val(lid);
			var url="/beadhouse/api/nurlevel/content/selectone";
			 $.get(url,{
				 levelId:lid,
				 contentId:cid
				 
			 },function(r){
				if(r.code==="ok"){
					console.log(r.data);
					$("#nurname").val(r.data.name);
					$("#selCycle").val(r.data.nurCycle);
					$("#times").val(r.data.nurTimes);
					$("#contentId").val(r.data.nurcontentId);
					
				}
			}); 
		}
		</script>
	</head>
	<body>
	
	<form action="/beadhouse/api/nurlevel/content/update" method="get">
	<input type="hidden" id="levelId" name="levelId" value="">
	<input type="hidden" id="contentId" name="contentId" value="">
	<div class="modal fade myModal2">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-label="Close">
								<span aria-hidden="true">&times;</span>
							</button>
							<span class="glyphicon glyphicon-pencil"></span>&nbsp;【修改护理内容】
						</div>
						<div class="modal-body clearfix" style="height: auto;">
							<div class="col-md-12 pd0">
								<div class="col-md-1 pd0 mt10"></div>
								<div class="col-md-10 pd0">
									<div class="col-md-12 pd0">
										<div class="input-group inputWidth">
											<span class="input-group-addon titleWidth">&nbsp;&nbsp;护理项目：</span>
											<input type="text"  readonly="readonly"  id="nurname" class="form-control" value="" aria-describedby="basic-addon1">
										</div>
									</div>
								</div>
								<div class="col-md-1 pd0"></div>
							</div>
							<div class="col-md-12 pd0 mt10">
								<div class="col-md-1 pd0"></div>
								<div class="col-md-10 pd0">
									<div class="col-md-12 pd0">
										<div class="input-group inputWidth">
											<span class="input-group-addon titleWidth">&nbsp;&nbsp;执行周期：</span>
											<select class="form-control" id="selCycle" name="nurCycle">
												<option value="每天">每天</option>
												<option value="每周">每周</option>
												<option value="每月">每月</option>
											</select>
										</div>
									</div>
								</div>
								<div class="col-md-1 pd0"></div>
							</div>
							<div class="col-md-12 pd0 mt10">
								<div class="col-md-1 pd0"></div>
								<div class="col-md-10 pd0">
									<div class="col-md-12 pd0">
										<div class="input-group inputWidth">
											<span class="input-group-addon titleWidth">&nbsp;&nbsp;执行次数：</span>
											<input type="text" value="" name="nurTimes" id="times" class="form-control" placeholder="请输入【执行次数】信息" aria-describedby="basic-addon1">
										</div>
									</div>
								</div>
								<div class="col-md-1 pd0"></div>
							</div>
							
							
						</div>
						<div class="modal-footer mt20">
							<button type="submit" class="btn btn-primary" >
								确定
							</button>
							<button type="button" class="btn btn-default" data-dismiss="modal">
								取消
							</button>
						</div>
					</div>
				</div>
			</div>
		</form>
	
	
		<div class="col-md-12 pd20 RightContentBody fmt10">
			<div class="col-md-9 pd0 fmt5">
				<button onclick="deleteAllContent()" class="btn btn-primary" data-toggle="modal" data-target=".myModal1"><span class="glyphicon glyphicon-plus" ></span>&nbsp;添加护理内容</button> 
			</div>
			<form action="/beadhouse/api/nurlevel/content/add" method="get">
			<input type="hidden" name="levelId" value="" id="nurLevelId">
			<div class="modal fade myModal1">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-label="Close">
								<span aria-hidden="true">&times;</span>
							</button>
							<span class="glyphicon glyphicon-pencil"></span>&nbsp;【添加护理内容】
						</div>
						<div class="modal-body clearfix" style="height: auto;">
							<div class="col-md-12 pd0">
								<div class="col-md-1 pd0 mt10"></div>
								<div class="col-md-10 pd0">
									<div class="col-md-12 pd0">
										<div class="input-group inputWidth">
											<span class="input-group-addon titleWidth">&nbsp;&nbsp;护理项目：</span>
											<select class="form-control" name="contentId" id="contentSelect">
												
											</select>
										</div>
									</div>
								</div>
								<div class="col-md-1 pd0"></div>
							</div>
							<div class="col-md-12 pd0 mt10">
								<div class="col-md-1 pd0"></div>
								<div class="col-md-10 pd0">
									<div class="col-md-12 pd0">
										<div class="input-group inputWidth">
											<span class="input-group-addon titleWidth">&nbsp;&nbsp;执行周期：</span>
											<select class="form-control" name="nurCycle">
												<option values="每天">每天</option>
												<option values="每周">每周</option>
												<option values="每月">每月</option>
											</select>
										</div>
									</div>
								</div>
								<div class="col-md-1 pd0"></div>
							</div>
							<div class="col-md-12 pd0 mt10">
								<div class="col-md-1 pd0"></div>
								<div class="col-md-10 pd0">
									<div class="col-md-12 pd0">
										<div class="input-group inputWidth">
											<span class="input-group-addon titleWidth">&nbsp;&nbsp;执行次数：</span>
											<input type="text" name="nurTimes" id="csmc" class="form-control" placeholder="请输入【执行次数】信息" aria-describedby="basic-addon1">
										</div>
									</div>
								</div>
								<div class="col-md-1 pd0"></div>
							</div>
							
							
						</div>
						<div class="modal-footer mt20">
							<button type="submit" class="btn btn-primary" >
								确定
							</button>
							<button type="button" class="btn btn-default" data-dismiss="modal">
								取消
							</button>
						</div>
					</div>
				</div>
			</div>
			</form>
			<div class="col-md-12 pd0 fmt10">
				<hr class="commonHRCss"/>
			</div>
			<div class="col-md-12 pd0">
				<table class="table table-hover">
					<thead>
						<tr>
							<th>序号</th>
							<th>护理内容</th>
							<th>执行周期</th>
							<th>执行次数</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
					<c:forEach items="${data.rows}"  var="r" varStatus="vs">
						<tr>
							<td>${vs.index}</td>
							<td>${data.rows[vs.index].name}</td>
							<td>${data.rows[vs.index].nurCycle}</td>
							<td>${data.rows[vs.index].nurTimes}</td>
							<td>
								
								<button class="btn btn-primary" data-toggle="modal" data-target=".myModal2" onclick="Values(${data.rows[vs.index].nurcontentId},${data.rows[vs.index].id})">修改</button> 
								
								<a href="/beadhouse/api/nurlevel/content/delete?id=${data.rows[vs.index].nurcontentId}&levelId=${data.rows[vs.index].id}" class="btn btn-danger" >删除</a>
							</td>
						</tr>
						</c:forEach>
					</tbody>
				</table>
			</div>
			
			<div style="text-align: right;" mt20">
				<a href="/beadhouse/api/nurlevel/selectList" target="">
					<button class="btn btn-success">返回</button>
				</a>
			</div>
		</div>
	</body>
</html>
